package com.ruoyi.project.dict.tag.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.dict.tag.mapper.MaterialTagMapper;
import com.ruoyi.project.dict.tag.domain.MaterialTag;
import com.ruoyi.project.dict.tag.service.IMaterialTagService;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;

/**
 * 学习资料标签Service业务层处理
 * 
 * @author shixiangwen
 * @date 2020-05-12
 */
@Service
@DataSource(DataSourceType.DICT)
public class MaterialTagServiceImpl implements IMaterialTagService {

	@Autowired
	private MaterialTagMapper materialTagMapper;

	/**
	 * 查询学习资料标签
	 * 
	 * @param id 学习资料标签ID
	 * @return 学习资料标签
	 */
	@Override
	public MaterialTag selectMaterialTagById(Long id) {
		return materialTagMapper.selectMaterialTagById(id);
	}

	/**
	 * 查询学习资料标签列表
	 * 
	 * @param materialTag 学习资料标签
	 * @return 学习资料标签
	 */
	@Override
	public List<MaterialTag> selectMaterialTagList(MaterialTag materialTag) {
		return materialTagMapper.selectMaterialTagList(materialTag);
	}

	/**
	 * 新增学习资料标签
	 * 
	 * @param materialTag 学习资料标签
	 * @return 结果
	 */
	@Override
	public int insertMaterialTag(MaterialTag materialTag) {
		materialTag.setCreateTime(DateUtils.getNowDate());
		return materialTagMapper.insertMaterialTag(materialTag);
	}

	/**
	 * 修改学习资料标签
	 * 
	 * @param materialTag 学习资料标签
	 * @return 结果
	 */
	@Override
	public int updateMaterialTag(MaterialTag materialTag) {
		materialTag.setUpdateTime(DateUtils.getNowDate());
		return materialTagMapper.updateMaterialTag(materialTag);
	}

	/**
	 * 删除学习资料标签对象
	 * 
	 * @param ids 需要删除的数据ID
	 * @return 结果
	 */
	@Override
	public int deleteMaterialTagByIds(String ids) {
		return materialTagMapper.deleteMaterialTagByIds(Convert.toStrArray(ids));
	}

	/**
	 * 删除学习资料标签信息
	 * 
	 * @param id 学习资料标签ID
	 * @return 结果
	 */
	@Override
	public int deleteMaterialTagById(Long id) {
		return materialTagMapper.deleteMaterialTagById(id);
	}
}
